import groovy.json.JsonSlurper
import groovy.json.JsonOutput

class Example{
    static void main(String[] args){
        def jsonSlurper = new JsonSlurper()
        def object = jsonSlurper.parseText('{"name":"lee","id":"1"}')

        println(object.name)
        println(object.id)


        Object list = jsonSlurper.parseText('{"List":[2,3,4,5]}')
        list.each { println it}

        def obj = jsonSlurper.parseText ''' {"Integer":12, "fraction": 12.55, "double": 12e13}'''
        println(obj.Integer)
        println(obj.fraction)
        println(obj.double)

        def output = JsonOutput.toJson([name: 'lee', id:1])
        println(output)

        def outputStu = JsonOutput.toJson([new Student(name: 'lee', id: 1), 
                new Student(name: 'kate',id:2)])
        println(outputStu)
    }
}

class Student{
    String name
    int id
}